<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>${title}</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="../res/layui/css/layui.css">
    <link rel="stylesheet" href="../res/static/css/mian.css">
    <style>
        .layui-form-label {
            width: 50px;
        }

        .layui-input-block {
            margin-left: 40px;
        }

        @media screen and (max-width: 450px) {
            .layui-form-item .layui-input-inline {
                margin: 0 0 10px 80px;
            }
        }

    </style>
</head>
<body class="lay-blog">
<#include "../common/header.ftl">
<div class="container-wrap">
    <div class="container">
        <div class="contar-wrap">
            <div class="item">
                <div class="item-box">
                    <form class="layui-form" action="">
                        <div class="layui-form-item">
                            <label class="layui-form-label">邮箱</label>
                            <div class="layui-input-inline">
                                <input type="text" name="username" required lay-verify="required"
                                       placeholder="请输入邮箱" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">密码</label>
                            <div class="layui-input-inline">
                                <input type="password" name="password" required lay-verify="required"
                                       placeholder="请输入密码"
                                       autocomplete="off" class="layui-input">
                            </div>

                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit="" lay-filter="login">登陆</button>
                                <a href="/page/reg" class="layui-btn layui-btn-primary">注册用户</a>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<#include "../common/footer.ftl">
<script src="../res/layui/layui.js"></script>
<script  src="../res/static/js/basePath.js"></script>
<script>
    layui.use(['form', 'jquery','layer'], function () {
        var form = layui.form
                , layer = layui.layer
                , $ = layui.jquery;

        //监听提交
        form.on('submit(login)', function (data) {
            var parameter = {
                type: "post",
                url: webPath+"/api/login",
                async: true,
                data: data.field,
                success: function (res) {
                    if(res.code==200&&res.message == "OK"){
                        location.href=webPath+"/page/backstage";
                    }else {
                        layer.msg(res.message)
                    }
                }
            };
            $.ajax(parameter);
            return false;
        });

    });
</script>
</body>
</html>